package com.eastcom.providor.service.extview;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.eastcom.bm.atom.Atom_NeType;
import com.eastcom.bm.atom.Atom_PublicNe;

public class PublicNeUtil {
	
	public static List<Atom_NeType> publicNeFilterNeType(List<Atom_PublicNe> pubNes,Map<String,Atom_NeType> filterMap){
		List<Atom_NeType> retList=new ArrayList<Atom_NeType>();
		if(pubNes==null||filterMap==null)
			return retList;
		for(Atom_PublicNe at:pubNes){
			Atom_NeType neT=filterMap.get(at.getNeType());
			if(neT!=null&&!retList.contains(neT)){
				retList.add(neT);
			}
		}
		return retList;
	}

	public static Map<String, Object> createPublicNeBean(Atom_PublicNe pNe) {
		Map<String, Object> retMap=new HashMap<String, Object>();
		if(pNe==null)
			return retMap;
		retMap.put("cn_name", pNe.getCn_name());
		retMap.put("id", pNe.getId());
		retMap.put("en_name", pNe.getEn_name());
		retMap.put("neType", pNe.getNeType());
		retMap.put("neWorkingState", pNe.getNeWorkingState());
		retMap.put("vendorName", pNe.getVendorName());
		retMap.put("timeStamp", pNe.getTimeStamp());
		return retMap;
	}
	
	public static Atom_PublicNe getPublicNeByArgs(Map<String, String> args){
		
		Atom_PublicNe ne=new Atom_PublicNe();
		ne.setId(args.get("id"));
		ne.setCn_name(args.get("cn_name"));
		ne.setEn_name(args.get("en_name"));
		ne.setNeType(args.get("neType"));
		ne.setNeWorkingState(args.get("neWorkingState"));
		ne.setVendorName(args.get("vendorName"));
		if(args.get("timeStamp")!=null)
			try{
				ne.setTimeStamp(new Date(Long.parseLong(args.get("timeStamp"))));
			}catch (Exception e) {
				e.printStackTrace();
			}
		else{
			ne.setTimeStamp(new Date());
		}
		return ne;
	}

}
